package game_elements_layer.guys_stuff.guys_actions;

import game_elements_layer.guys_stuff.Guys;
import game_elements_layer.field_stuff.locations_stuff.NoContainedProductionFound;
import game_elements_layer.resourses_stuff.Alcohol;
import game_elements_layer.resourses_stuff.Drugs;
import game_elements_layer.resourses_stuff.Guns;
import game_elements_layer.resourses_stuff.Resources;

/**
 * Created with IntelliJ IDEA.
 * User: Slava
 * Date: 06.10.14
 * Time: 22:33
 * To change this template use File | Settings | File Templates.
 */
public class GuysGatherResourcesAction extends GuysActions{
    Guys guy;

    public GuysGatherResourcesAction(Guys guy) throws NoContainedProductionFound {
        if (this.guy.getCurrentLocation().getContainedProduction() == null)
            throw new NoContainedProductionFound("Exception rised while "+guy+" tryed to find production in "+guy.getCurrentLocation());
        this.guy = guy;
    }

    @Override
    public void perform() {
        Resources income = this.guy.getCurrentLocation().getContainedProduction().getIncomePerRound();
        if (Alcohol.class.isInstance(income))
            guy.getGuysOwner().earnAlcohol(income.getAmount());
        if (Guns.class.isInstance(income))
            guy.getGuysOwner().earnGuns(income.getAmount());
        if (Drugs.class.isInstance(income))
            guy.getGuysOwner().earnDrugs(income.getAmount());
    }
}
